package com.golxen.framework.user.player;


import com.golxen.framework.event.condition.ConditionPlugin;
import com.golxen.framework.event.condition.dao.entity.UserConditionData;
import com.golxen.framework.event.eGamePlayerEventType;
import com.golxen.framework.executor.ThreadPlugin;
import com.golxen.framework.module.ModulePlugin;
import com.golxen.framework.timers.TimerPlugin;
import com.golxen.framework.user.player.condition.LoginDaysCondition;

import java.util.concurrent.TimeUnit;

public class PlayerPlugin {

	static PlayerPlugin instance = null;

	public static void start() {
		if (instance != null) {
			return;
		}

		instance = new PlayerPlugin();

		ModulePlugin.registModule(PlayerModule.class);

		TimerPlugin.registTimer(PlayerDataSaveTask.class, 1, 3, TimeUnit.SECONDS, ThreadPlugin.getCpu());
		TimerPlugin.registTimer(PlayerHeartCheckTask.class, 10, 5, TimeUnit.SECONDS);

		// 登录天数
		ConditionPlugin.registCommonCondition(eGamePlayerEventType.LoginDays, LoginDaysCondition::new);

	}

	public static boolean active() {
		return instance != null;
	}

}
